home *** CD-ROM | disk | FTP | other *** search
- /* Test-plugin v1.1 rev.#2 by Deniil 715! for MultiRen
- Made 2000-07-04
-
- E-mail to me, Daniel Westerberg: deniil@algonet.se
- */
-
- CONST NUMSTRINGS_FOR_THIS_PLUGIN=2, FILE_NAME_LENGTH=512,
- COM_ASK=1, COM_EXTRACT=2, COM_CONFIGURE=3, COM_ABOUT=4, COM_QUIT=5,
- ERR_OK=0,
- ERR_NOMEM=1,
- ERR_NOFILE=2,
- ERR_NOSIG=3,
- ERR_NOTIMPL=4,
- ERR_UNKNOWN=5,
- ERR_OTHER=6,
- ERR_WRONGFORMAT=7,
- ERR_NOINFO=8,
- ERR_FATAL=20
-
- OBJECT multiren_plugin
- id:LONG
- task:LONG
- sig:LONG
- return:INT
- command:CHAR
- numstrings:CHAR /* You will */
- stringlist[256]:ARRAY OF LONG /* only use */
- name:PTR TO CHAR /* these 4 */
- newname:CHAR /* elements */
- ENDOBJECT
-
- DEF mrp:PTR TO multiren_plugin, hex[8]:STRING, ascii[4]:STRING
-
- PROC main()
- DEF sel, sigbit, sig, mtask, msig
- '$VER: TestPlugin v1.1 rev.#2 by Deniil 715! (2000-07-04)'
- IF arg
- IF mrp:=Val(arg)
- IF mrp.id="MRPO"
- IF (sigbit:=AllocSignal(-1))>=0
- sig:=Shl(1,sigbit)
- LOOP
- sel:=mrp.command
- SELECT sel
- CASE COM_ASK
- mtask:=mrp.task
- msig:=mrp.sig
- mrp.return:=ask()
- SetProgramName(mrp.name)
- mrp.task:=FindTask(NIL)
- mrp.sig:=sig
- CASE COM_EXTRACT ; mrp.return:=extract()
- CASE COM_CONFIGURE ; mrp.return:=config()
- CASE COM_ABOUT ; mrp.return:=about()
- CASE COM_QUIT
- FreeSignal(sigbit)
- mrp.return:=cleanup()
- Signal(mtask,msig)
- RETURN
- DEFAULT ; mrp.return:=ERR_UNKNOWN
- ENDSELECT
- Signal(mtask,msig)
- Wait(sig)
- ENDLOOP
- ELSE
- Signal(mrp.task,mrp.sig)
- mrp.return:=ERR_NOSIG
- RETURN
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- WriteF('This is a plugin for MultiRen!\n' +
- 'It is not supposed to be executed manually!\n' +
- 'Use it through the Renplacer tool in MultiRen instead!\n')
- ENDPROC ERR_FATAL
-
- PROC ask()
- mrp.numstrings:=NUMSTRINGS_FOR_THIS_PLUGIN -> I will return 2 strings
- mrp.stringlist[0]:='First 4 bytes as hex' -> Setting information-strings
- mrp.stringlist[1]:='First 4 bytes as ASCII'
- mrp.name:='Test Plugin' -> This plugins name
- mrp.newname:=FALSE -> This plugin reads info from the file and it is
- -> therefor unwise to request newname as it changes
- -> and the file will not be found.
- ENDPROC ERR_OK
-
- PROC extract() -> Do my stuff..
- DEF fh, len
- IF FileLength(mrp.name)<4 THEN RETURN ERR_NOINFO
- IF fh:=Open(mrp.name,OLDFILE) -> Open the file that later is going to be renamed.
- len:=Read(fh,ascii,4)
- Close(fh)
- IF len<>4 THEN RETURN ERR_OTHER
- SetStr(ascii,4)
- StringF(hex,'\r\z\h\z\h\z\h\z\h',ascii[0],ascii[1],ascii[2],ascii[3])
- mrp.stringlist[0]:=hex -> Set the pointers so that MultiRen
- mrp.stringlist[1]:=ascii -> can get my strings.
- RETURN ERR_OK -> My stuff went ok
- ENDIF
- ENDPROC ERR_NOFILE -> The file didn't open
-
- PROC config() IS ERR_NOTIMPL -> There is no config for this plugin
-
- PROC about()
- IF req('Test Plugin v1.1 rev.#2 by Deniil 715! for MultiRen\n\n' +
- 'It was made 2000-07-04 in Amiga-E\n\n' +
- 'E-mail: deniil@algonet.se','More|OK')
- req('This plugin will return the first 4 bytes\n' +
- 'of the file to rename in two ways. The first\n' +
- 'string will be the 4 bytes in hexadecimal,\n' +
- 'the other one just as a plain string.','OK')
- ENDIF
- ENDPROC ERR_OK
-
- PROC cleanup() IS ERR_OK
-
- PROC req(body,gads) IS EasyRequestArgs(NIL,[20,0,'Test Plugin',body,gads],NIL,NIL)